import { createStore } from 'vuex';
import { selectStationApi } from "@/api/station";

export default createStore({
    state: {
        // 是否初始化
        isInit:true,
        // 站点信息
        stationInfo:{},
    },
    mutations: {
        saveStationInfo(state,stationInfo){
            state.stationInfo = stationInfo;
        },
        saveIsInit(state,isInit){
            state.isInit = isInit;
        }
    },
    actions: {
        async updateStationInfo(context){
            let res = await selectStationApi();
            await context.commit('saveStationInfo',res.data);
        },
        async updateIsInit(context,isInit){
            await context.commit('saveIsInit',isInit);
        }
    },
    getters: {
        /** 获取站点信息 */
        geStationInfo(state){
            return state.stationInfo;
        },
        /** 获取是否初始化 */
        geIsInit(state){
            return state.isInit;
        }
    }
})

